package com.codejoys.monitor.dto;

public class BaseResult {
    private Integer code;
    private String message;

    private Object data;

    public BaseResult() {}

    public BaseResult(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public BaseResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static BaseResult success() {
        return new BaseResult(0, "success");
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private String message;
        private Integer code;
        private Object data;

        private Builder() {}

        public Builder code(Integer code) {
            this.code = code;
            return this;
        }

        public Builder message(String message) {
            this.message = message;
            return this;
        }

        public Builder data(Object data) {
            this.data = data;
            return this;
        }

        public Builder success() {
            this.code = 0;
            this.message = "success";

            return this;
        }

        public BaseResult build() {
            BaseResult result = new BaseResult();
            result.code = this.code;
            result.message = this.message;
            result.data = this.data;
            return result;
        }
    }
}
